home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / mfb / RCS / mfbscrinit.c,v < prev    next >
Encoding:
Text File  |  1991-02-24  |  7.4 KB  |  255 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     91.02.23.23.03.56;  author kupfer;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     90.02.14.19.58.23;  author tve;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @Original X11R4 distribution
  22. @
  23.  
  24.  
  25. 1.2
  26. log
  27. @MIT Patch #2.
  28. @
  29. text
  30. @/***********************************************************
  31. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  32. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  33.  
  34.                         All Rights Reserved
  35.  
  36. Permission to use, copy, modify, and distribute this software and its 
  37. documentation for any purpose and without fee is hereby granted, 
  38. provided that the above copyright notice appear in all copies and that
  39. both that copyright notice and this permission notice appear in 
  40. supporting documentation, and that the names of Digital or MIT not be
  41. used in advertising or publicity pertaining to distribution of the
  42. software without specific, written prior permission.  
  43.  
  44. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  45. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  46. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  47. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  48. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  49. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  50. SOFTWARE.
  51.  
  52. ******************************************************************/
  53. /* $XConsortium: mfbscrinit.c,v 5.10 90/01/23 15:39:27 rws Exp $ */
  54.  
  55. #include "X.h"
  56. #include "Xproto.h"    /* for xColorItem */
  57. #include "Xmd.h"
  58. #include "scrnintstr.h"
  59. #include "pixmapstr.h"
  60. #include "resource.h"
  61. #include "colormap.h"
  62. #include "mfb.h"
  63. #include "mistruct.h"
  64. #include "dix.h"
  65. #include "mi.h"
  66. #include "mibstore.h"
  67. #include "servermd.h"
  68.  
  69. extern RegionPtr mfbPixmapToRegion();
  70.  
  71. int mfbWindowPrivateIndex;
  72. int mfbGCPrivateIndex;
  73. static unsigned long mfbGeneration = 0;
  74.  
  75. static VisualRec visual = {
  76. /* vid  class       bpRGB cmpE nplan rMask gMask bMask oRed oGreen oBlue */
  77.    0,   StaticGray, 1,    2,   1,    0,    0,    0,    0,   0,     0
  78. };
  79.  
  80. static VisualID VID;
  81.  
  82. static DepthRec depth = {
  83. /* depth    numVid        vids */
  84.     1,        1,        &VID
  85. };
  86.  
  87. miBSFuncRec mfbBSFuncRec = {
  88.     mfbSaveAreas,
  89.     mfbRestoreAreas,
  90.     (void (*)()) 0,
  91.     (PixmapPtr (*)()) 0,
  92.     (PixmapPtr (*)()) 0,
  93. };
  94.  
  95. Bool
  96. mfbAllocatePrivates(pScreen, pWinIndex, pGCIndex)
  97.     ScreenPtr pScreen;
  98.     int *pWinIndex, *pGCIndex;
  99. {
  100.     if (mfbGeneration != serverGeneration)
  101.     {
  102.     mfbWindowPrivateIndex = AllocateWindowPrivateIndex();
  103.     mfbGCPrivateIndex = AllocateGCPrivateIndex();
  104.     visual.vid = FakeClientID(0);
  105.     VID = visual.vid;
  106.     mfbGeneration = serverGeneration;
  107.     }
  108.     if (pWinIndex)
  109.     *pWinIndex = mfbWindowPrivateIndex;
  110.     if (pGCIndex)
  111.     *pGCIndex = mfbGCPrivateIndex;
  112.     return (AllocateWindowPrivate(pScreen, mfbWindowPrivateIndex,
  113.                   sizeof(mfbPrivWin)) &&
  114.         AllocateGCPrivate(pScreen, mfbGCPrivateIndex, sizeof(mfbPrivGC)));
  115. }
  116.  
  117. /* dts * (inch/dot) * (25.4 mm / inch) = mm */
  118. Bool
  119. mfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
  120.     register ScreenPtr pScreen;
  121.     pointer pbits;        /* pointer to screen bitmap */
  122.     int xsize, ysize;        /* in pixels */
  123.     int dpix, dpiy;        /* dots per inch */
  124.     int width;            /* pixel width of frame buffer */
  125. {
  126.     register PixmapPtr pPixmap;
  127.  
  128.     if     (!mfbAllocatePrivates(pScreen, (int *)NULL, (int *)NULL))
  129.     return FALSE;
  130.     pPixmap = (PixmapPtr)xalloc(sizeof(PixmapRec));
  131.     if (!pPixmap)
  132.     return FALSE;
  133.  
  134.     pScreen->width = xsize;
  135.     pScreen->height = ysize;
  136.     pScreen->mmWidth = (xsize * 254) / (dpix * 10);
  137.     pScreen->mmHeight = (ysize * 254) / (dpiy * 10);
  138.     pScreen->numDepths = 1;
  139.     pScreen->allowedDepths = &depth;
  140.  
  141.     pScreen->rootDepth = 1;
  142.     pScreen->rootVisual = VID;
  143.     pScreen->defColormap = (Colormap) FakeClientID(0);
  144.     pScreen->minInstalledCmaps = 1;
  145.     pScreen->maxInstalledCmaps = 1;
  146.     pScreen->backingStoreSupport = Always;
  147.     pScreen->saveUnderSupport = NotUseful;
  148.  
  149.     /* cursmin and cursmax are device specific */
  150.  
  151.     pScreen->numVisuals = 1;
  152.     pScreen->visuals = &visual;
  153.  
  154.     pPixmap->drawable.type = DRAWABLE_PIXMAP;
  155.     pPixmap->drawable.depth = 1;
  156.     pPixmap->drawable.pScreen = pScreen;
  157.     pPixmap->drawable.serialNumber = 0;
  158.     pPixmap->drawable.x = 0;
  159.     pPixmap->drawable.y = 0;
  160.     pPixmap->drawable.width = xsize;
  161.     pPixmap->drawable.height = ysize;
  162.     pPixmap->refcnt = 1;
  163.     pPixmap->devPrivate.ptr = pbits;
  164.     pPixmap->devKind = PixmapBytePad(width, 1);
  165.     pScreen->devPrivate = (pointer)pPixmap;
  166.  
  167.     /* anything that mfb doesn't know about is assumed to be done
  168.        elsewhere.  (we put in no-op only for things that we KNOW
  169.        are really no-op.
  170.     */
  171.     pScreen->CreateWindow = mfbCreateWindow;
  172.     pScreen->DestroyWindow = mfbDestroyWindow;
  173.     pScreen->PositionWindow = mfbPositionWindow;
  174.     pScreen->ChangeWindowAttributes = mfbChangeWindowAttributes;
  175.     pScreen->RealizeWindow = mfbMapWindow;
  176.     pScreen->UnrealizeWindow = mfbUnmapWindow;
  177.  
  178.     pScreen->RealizeFont = mfbRealizeFont;
  179.     pScreen->UnrealizeFont = mfbUnrealizeFont;
  180.     pScreen->CloseScreen = mfbCloseScreen;
  181.     pScreen->QueryBestSize = mfbQueryBestSize;
  182.     pScreen->GetImage = mfbGetImage;
  183.     pScreen->GetSpans = mfbGetSpans;
  184.     pScreen->SourceValidate = (void (*)()) 0;
  185.     pScreen->CreateGC = mfbCreateGC;
  186.     pScreen->CreatePixmap = mfbCreatePixmap;
  187.     pScreen->DestroyPixmap = mfbDestroyPixmap;
  188.     pScreen->ValidateTree = miValidateTree;
  189.  
  190.     pScreen->InstallColormap = mfbInstallColormap;
  191.     pScreen->UninstallColormap = mfbUninstallColormap;
  192.     pScreen->ListInstalledColormaps = mfbListInstalledColormaps;
  193.     pScreen->StoreColors = NoopDDA;
  194.     pScreen->ResolveColor = mfbResolveColor;
  195.     pScreen->CreateColormap = mfbCreateColormap;
  196.     pScreen->DestroyColormap = mfbDestroyColormap;
  197.  
  198.     pScreen->RegionCreate = miRegionCreate;
  199.     pScreen->RegionInit = miRegionInit;
  200.     pScreen->RegionCopy = miRegionCopy;
  201.     pScreen->RegionDestroy = miRegionDestroy;
  202.     pScreen->RegionUninit = miRegionUninit;
  203.     pScreen->Intersect = miIntersect;
  204.     pScreen->Inverse = miInverse;
  205.     pScreen->Union = miUnion;
  206.     pScreen->Subtract = miSubtract;
  207.     pScreen->RegionReset = miRegionReset;
  208.     pScreen->TranslateRegion = miTranslateRegion;
  209.     pScreen->RectIn = miRectIn;
  210.     pScreen->PointInRegion = miPointInRegion;
  211.     pScreen->WindowExposures = miWindowExposures;
  212.     pScreen->PaintWindowBackground = mfbPaintWindow;
  213.     pScreen->PaintWindowBorder = mfbPaintWindow;
  214.     pScreen->CopyWindow = mfbCopyWindow;
  215.     pScreen->ClearToBackground = miClearToBackground;
  216.  
  217.     pScreen->RegionNotEmpty = miRegionNotEmpty;
  218.     pScreen->RegionEmpty = miRegionEmpty;
  219.     pScreen->RegionExtents = miRegionExtents;
  220.     pScreen->RegionAppend = miRegionAppend;
  221.     pScreen->RegionValidate = miRegionValidate;
  222.     pScreen->BitmapToRegion = mfbPixmapToRegion;
  223.     pScreen->RectsToRegion = miRectsToRegion;
  224.     pScreen->SendGraphicsExpose = miSendGraphicsExpose;
  225.  
  226.     pScreen->BlockHandler = NoopDDA;
  227.     pScreen->WakeupHandler = NoopDDA;
  228.     pScreen->blockData = (pointer)NULL;
  229.     pScreen->wakeupData = (pointer)NULL;
  230.  
  231.     miInitializeBackingStore (pScreen, &mfbBSFuncRec);
  232. #ifdef MITSHM
  233.     ShmRegisterFbFuncs(pScreen);
  234. #endif
  235.     return TRUE;
  236. }
  237. @
  238.  
  239.  
  240. 1.1
  241. log
  242. @Initial revision
  243. @
  244. text
  245. @d24 1
  246. a24 1
  247. /* $XConsortium: mfbscrinit.c,v 5.9 89/09/12 14:25:48 keith Exp $ */
  248. a77 4
  249.     if (pWinIndex)
  250.         *pWinIndex = mfbWindowPrivateIndex;
  251.     if (pGCIndex)
  252.         *pGCIndex = mfbGCPrivateIndex;
  253. d79 4
  254. @
  255.